<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('调课申请列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <p>处理状态：</p>
                            <select name="operateStatus" th:with="type=${@dict.getType('course_operate_status')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <p>处理结果：</p>
                            <select name="operateResult" th:with="type=${@dict.getType('course_operate_result')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i> 搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i> 重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="col-sm-12 select-table table-bordered">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var operateStatusDatas = [[${@dict.getType('course_operate_status')}]];
    var operateResultDatas = [[${@dict.getType('course_operate_result')}]];
    var timeSlotDatas = [[${@dict.getType('course_time_slot')}]];
    var prefix = ctx + "mgr/adjust";

    $(function () {
        var options = {
            url: prefix + "/list",
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            modalName: "调课申请",
            columns: [
                [{
                    title: '申请调课信息',
                    align: 'center',
                    colspan: 6
                }, {
                    title: '调课信息',
                    align: 'center',
                    colspan: 5
                },
                    {
                        title: '其他信息',
                        align: 'center',
                        colspan: 9
                    }
                ],
                [{
                    checkbox: true
                },
                    {
                        field: 'id',
                        visible: false
                    },
                    {
                        field: 'arrangeId',
                        visible: false
                    },
                    {
                        field: 'afterArrangeId',
                        visible: false
                    },
                    {
                        field: 'teacherName',
                        title: '申请人'
                    },
                    {
                        field: 'roomCode',
                        title: '教室'
                    },
                    {
                        field: 'courseDate',
                        title: '课程时间'
                    },
                    {
                        field: 'courseName',
                        title: '课程'
                    },
                    {
                        field: 'timeSlot',
                        title: '时间段',
                        formatter: function (value, row, index) {
                            return $.table.selectDictLabel(timeSlotDatas, value);
                        }
                    },

                    {
                        field: 'nowTeacherName',
                        title: '教师'
                    },
                    {
                        field: 'nowRommCode',
                        title: '教室'
                    },
                    {
                        field: 'nowCourseDate',
                        title: '课程时间'
                    },
                    {
                        field: 'nowCourseName',
                        title: '课程'
                    },
                    {
                        field: 'nowTimeSlot',
                        title: '时间段',
                        formatter: function (value, row, index) {
                            return $.table.selectDictLabel(timeSlotDatas, value);
                        }
                    },

                    {
                        field: 'operateStatus',
                        title: '处理状态',
                        formatter: function (value, row, index) {
                            return $.table.selectDictLabel(operateStatusDatas, value);
                        }
                    },
                    {
                        field: 'operateResult',
                        title: '处理结果',
                        formatter: function (value, row, index) {
                            return $.table.selectDictLabel(operateResultDatas, value);
                        }
                    },
                    {
                        field: 'reason',
                        title: '拒绝理由'
                    },
                    {
                        field: 'initiateTime',
                        title: '发起时间'
                    },
                    {
                        field: 'type',
                        title: '类型',
                        formatter: function (value, row, index) {
                            return foramtType(row);
                        }
                    },
                    {
                        title: '操作',
                        align: 'center',
                        formatter: function (value, row, index) {
                            var actions = [];
                            if (row.operateStatus == 0) {
                                actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="agree(\'' + row.id + '\')"><i class="fa fa-edit"></i>同意</a> ');
                                actions.push('<a class="btn btn-danger btn-xs " href="javascript:void(0)" onclick="openRefuse(\'' + row.id + '\')"><i class="fa fa-remove"></i>拒绝</a>');
                            }
                            return actions.join('');
                        }
                    }
                ]
            ]
        };
        $.table.init(options);
    });
    function agree(id) {
        var url = prefix + '/agree/' + id;
        $.operate.get(url);
    }

    function openRefuse(id) {
        var url = prefix + '/openRefuse/' + id;
        $.modal.open("填写拒绝理由", url);
    }

    function foramtType(row) {
        if (row.type == '0') {
            return '换课';
        } else {
            return '调课';
        }
    }
</script>
</body>
</html>